package jjn.carl.hashtable;

/**
 * @author Jiang Jining
 * @since 2023-07-04 21:45
 */
public class LeetCode383 {
    public boolean canConstruct(String ransomNote, String magazine) {
        int[] charCount = new int[26];
        for (char c : ransomNote.toCharArray()) {
            charCount[c - 'a']++;
        }
        for (char c : magazine.toCharArray()) {
            charCount[c - 'a']--;
        }
        for (int j : charCount) {
            if (j > 0) {
                return false;
            }
        }
        return true;
    }
    
    public static void main(String[] args) {
        String ransomNote = "aa", magazine = "aab";
        boolean canConstruct = new LeetCode383().canConstruct(ransomNote, magazine);
        System.out.println("canConstruct = " + canConstruct);
    }
}
